<?php require_once('../Connections/embCon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_embCon, $embCon);
$query_ultimasEnergias = "SELECT    p.edificios_id,   p.valor,   p.energia_id,   edificios.descricao FROM   energia p   INNER JOIN ultimos_temp_en pm ON (p.edificios_id = pm.edificios_id)   AND (p.energia_id = pm.minenergia_id)   INNER JOIN edificios ON (p.edificios_id = edificios.edificios_id)";
$ultimasEnergias = mysql_query($query_ultimasEnergias, $embCon) or die(mysql_error());
$row_ultimasEnergias = mysql_fetch_assoc($ultimasEnergias);
$totalRows_ultimasEnergias = mysql_num_rows($ultimasEnergias);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Portal EMB</title>
<script type="text/javascript" src="../open_js_gauges_1.0/js/mootools-core-1.3-full-compat.js"></script> 
	<script type="text/javascript" src="../open_js_gauges_1.0/js/controller.js"></script> 
<link href="../styles/main.css" rel="stylesheet" type="text/css" /><!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* this 1px negative margin can be placed on any of the columns in this layout with the same corrective effect. */
ul.nav a { zoom: 1; }  /* the zoom property gives IE the hasLayout trigger it needs to correct extra whiltespace between the links */
</style>
<![endif]-->
</head>
<div class="container">
  <div class="header"><a href="#"><img src="../pictures/balum_g.gif" alt="Insert Logo Here" name="Insert_logo" width="149" height="206" id="Insert_logo" style="font-size: 100%; text-align: center; vertical-align: middle;" /></a> 
    <!-- end .header -->ESQUADRA DE MANUTENÇÃO BASE</div>
  <div class="sidebar1">
  <div class="link_separator"> </div>
    <ul class="nav">
      <li class="link_title">Gestão de Energia</li>
      <li><a href="#">Consumos instântaneos</a></li>
      <li><a href="#">Consumo diário</a></li>
      <li><a href="#">Consumo mensal</a></li>
      <li><a href="#">Link four</a>    <!-- end .sidebar1 --></li>
    </ul>
  </div>
  <div class="content">




    <h1>Consumos Energéticos    </h1>
    <table border="1">
      <tr>
        <td>Infra-Estrutura</td>
        <td>Consumo (KWh)</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><?php echo $row_ultimasEnergias['descricao']; ?></td>
          <td><?php echo $row_ultimasEnergias['valor']; ?></td>
        </tr>
        <?php } while ($row_ultimasEnergias = mysql_fetch_assoc($ultimasEnergias)); ?>
    </table>
<h2>&nbsp;</h2>
  <!-- end .content --></div>
  <div class="footer">
    <p>Sistema de informação criado por Capitão José Barros. LP </p>
    <!-- end .footer --></div>
  <!-- end .container --></div>

<script type="text/javascript"> 
			// <![CDATA[
		var so = new SWFObject("open_js_gauges_1.0/flash/meter.swf", "meter", "200", "180", "9", "#000000");
		
		//so.addVariable("funcName", "meter_data"); //Required!
		//so.addVariable("refresh", "5500"); //Required! 2000 = secs
		so.addVariable("bgimage", "open_js_gauges_1.0/images/meter.jpg"); 
		//so.addVariable("exec_type", "asp"); // Default: php Options: asp, js, whatever you choose.
		so.addVariable("title", "Potência Total"); 
		//so.addVariable("title_color", "black"); // Default: silver. Options: black, white, 
		
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		
	
		
		so.write("meter");
		// ]]>
	</script> 
    
</body>
<script type="text/javascript"> 
		window.document.meter.SetVariable("range", "100");
		window.document.meter.SetVariable("mValue", "10");
	</script> 
</html>
<?php
mysql_free_result($ultimasEnergias);
?>
